package com.mycompany.screens;

import com.mycompany.chatapp.Databaseacces.ImpDBAction;
import com.mycompany.chatapp.Databaseacces.ImpDBActionResult;
import com.mycompany.chatapp.Databaseacces.Photo;
import com.mycompany.chatapp.ImpInstantMessage;
import com.mycompany.chatapp.InstantMessage;
import java.awt.Cursor;
import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import org.apache.log4j.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ShowThumbnails.java
 *
 * Created on 23-feb-2012, 12:06:31
 */
/**
 *
 * @author Carlos
 */
public class ShowThumbnails extends javax.swing.JFrame {

    private final static Logger log = Logger.getLogger(ShowThumbnails.class);
    
    /** Creates new form ShowThumbnails */
    
    public ShowThumbnails() {
        title=new String[8];
        for(int j=0;j<8;j++){
            title[j]=" ";
        }
        initComponents();
        removeButtons();
        //this.setVisible(true);
    }
    public ShowThumbnails(List<Object> ph,ImpInstantMessage im, String userTo) {
        this.im=im;
        this.userTo=userTo;
        this.ph=ph;
        this.showMyImages();
        Photo photo=new Photo();
        int i=0;
        //title=new String[ph.size()];
        title=new String[8];
        log.info("dins typeOfResult 3 "+i );
        for(int j=0;j<8;j++){
            title[j]=" ";
        }
        log.info("dins typeOfResult 3 "+i );
        log.info("dins typeOfResult 4 " +title[i]);
        for (Object o: ph){
            photo=(Photo)o;
           // title[i]=photo.getTitle();
            //title[1]="";
            title[i]=photo.getTitle();
            
            log.info("dins typeOfResult 3 "+i );
            log.info("dins typeOfResult 4 " +title[i]);
            i++; 
        }
    
        initComponents();
            

      removeButtons();
        int b=ph.size();
        String but="jButton";
        String num = ""+b+"";
        String fin=but+num;
        
            if (b==0){
                jPanel1.remove(jButton4);
                jPanel1.remove(jButton5);
                jPanel1.remove(jButton6);
                jPanel1.remove(jButton8);
                jPanel1.remove(jButton9);
                jPanel1.remove(jButton10);
                
            }
            if (b==1){
                jPanel1.remove(jButton5);
                jPanel1.remove(jButton6);
                jPanel1.remove(jButton8);
                jPanel1.remove(jButton9);
                jPanel1.remove(jButton10);
                
            }
            if (b==2){
                jPanel1.remove(jButton6);
                jPanel1.remove(jButton8);
                jPanel1.remove(jButton9);
                jPanel1.remove(jButton10);
                
            }
            if (b==3){
                jPanel1.remove(jButton8);
                jPanel1.remove(jButton9);
                jPanel1.remove(jButton10);
                
            }
            if (b==4){
                jPanel1.remove(jButton9);
                jPanel1.remove(jButton10);
            }
            if (b==5){
                jPanel1.remove(jButton10);
            }
        
        
        jPanel1.repaint();
        jPanel1.revalidate();
    }
    
    private void removeButtons(){
        //hasta 8
       
        int b=list.size();
        
            if (b==0){
                jPanel2.remove(jButton12);
                jPanel2.remove(jButton13);
                jPanel2.remove(jButton14);
                jPanel2.remove(jButton15);
                jPanel2.remove(jButton16);
                jPanel2.remove(jButton17);
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
                
            }
            if (b==1){
                jPanel2.remove(jButton13);
                jPanel2.remove(jButton14);
                jPanel2.remove(jButton15);
                jPanel2.remove(jButton16);
                jPanel2.remove(jButton17);
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
                
            }
            if (b==2){
                jPanel2.remove(jButton14);
                jPanel2.remove(jButton15);
                jPanel2.remove(jButton16);
                jPanel2.remove(jButton17);
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
                
            }
            if (b==3){
                 jPanel2.remove(jButton15);
                jPanel2.remove(jButton16);
                jPanel2.remove(jButton17);
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
                
            }
            if (b==4){
                jPanel2.remove(jButton16);
                jPanel2.remove(jButton17);
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
            }
            if (b==5){
                jPanel2.remove(jButton17);
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
            }
            if (b==6){
                jPanel2.remove(jButton18);
                jPanel2.remove(jButton19);
            }
            if (b==7){
                jPanel2.remove(jButton19);
            }
        
        jPanel2.repaint();
        jPanel2.revalidate();
        
    }
    
    public void openURL (String url){
        
        try{
        java.awt.Desktop myNewBrowserDesktop = java.awt.Desktop.getDesktop();
        java.net.URI myNewLocation = new java.net.URI(url);
        myNewBrowserDesktop.browse( myNewLocation );
        } catch (Exception e){
            
        }
        
    } 

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton2 = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jButton7 = new javax.swing.JButton();
        jLabel18 = new javax.swing.JLabel();
        jButton11 = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton2.setText("LogOut");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton1.setText("Back");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel14.setIcon(icon1);
        jLabel14.setPreferredSize(new java.awt.Dimension(100, 100));
        jLabel14.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabel14MouseExited(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jLabel14MouseEntered(evt);
            }
        });

        jLabel1.setText(title[0]);

        jLabel2.setText(title[1]);

        jLabel3.setText(title[2]);

        jLabel4.setText(title[3]);

        jLabel5.setText(title[4]);

        jLabel6.setText(title[5]);

        jButton4.setText("Download");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Download");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Download");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton8.setText("Download");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText("Download");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setText("Download");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(109, 109, 109)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel1)
                    .add(jLabel4))
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                        .add(162, 162, 162)
                        .add(jLabel2)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 154, Short.MAX_VALUE)
                        .add(jLabel3)
                        .add(9, 9, 9))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                        .add(172, 172, 172)
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 130, Short.MAX_VALUE)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton6)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel6))))
                .add(142, 142, 142))
            .add(jPanel1Layout.createSequentialGroup()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(16, 16, 16)
                        .add(jButton1))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(86, 86, 86)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel1Layout.createSequentialGroup()
                                .add(jButton4)
                                .add(149, 149, 149)
                                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jPanel1Layout.createSequentialGroup()
                                        .add(jButton5)
                                        .add(0, 248, Short.MAX_VALUE))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .add(jButton9)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 141, Short.MAX_VALUE)
                                        .add(jButton10)))))))
                .addContainerGap(131, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
            .add(jPanel1Layout.createSequentialGroup()
                .add(75, 75, 75)
                .add(jButton8)
                .addContainerGap(646, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .add(6, 6, 6)
                .add(jButton1)
                .add(29, 29, 29)
                .add(jLabel14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(28, 28, 28)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jLabel2)
                    .add(jLabel3))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton4)
                    .add(jButton5)
                    .add(jButton6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 110, Short.MAX_VALUE)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(jLabel5)
                    .add(jLabel6))
                .add(18, 18, 18)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton8)
                    .add(jButton9)
                    .add(jButton10))
                .add(17, 17, 17))
        );

        jTabbedPane1.addTab("Search", jPanel1);

        jButton7.setText("Upload picture");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jLabel18.setText(titleMyphoto[0]);

        jButton11.setText("Slideshow");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        jLabel19.setText(titleMyphoto[1]);

        jLabel20.setText(titleMyphoto[2]);

        jLabel21.setText(titleMyphoto[4]);

        jLabel22.setText(titleMyphoto[3]);

        jLabel23.setText(titleMyphoto[5]);

        jLabel24.setText(titleMyphoto[7]);

        jLabel25.setText(titleMyphoto[6]);

        jButton12.setText("Show");
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        jButton13.setText("Show");
        jButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton13ActionPerformed(evt);
            }
        });

        jButton14.setText("Show");
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jButton15.setText("Show");
        jButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton15ActionPerformed(evt);
            }
        });

        jButton16.setText("Show");
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });

        jButton17.setText("Show");
        jButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton17ActionPerformed(evt);
            }
        });

        jButton18.setText("Show");
        jButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton18ActionPerformed(evt);
            }
        });

        jButton19.setText("Show");
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(29, 29, 29)
                .add(jButton7)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 519, Short.MAX_VALUE)
                .add(jButton11)
                .add(37, 37, 37))
            .add(jPanel2Layout.createSequentialGroup()
                .add(99, 99, 99)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel24)
                        .add(18, 18, 18)
                        .add(jButton19))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel25)
                        .add(18, 18, 18)
                        .add(jButton18))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel23)
                        .add(18, 18, 18)
                        .add(jButton17))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel21)
                        .add(18, 18, 18)
                        .add(jButton16))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel22)
                        .add(18, 18, 18)
                        .add(jButton15))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel20)
                        .add(18, 18, 18)
                        .add(jButton14))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel19)
                        .add(18, 18, 18)
                        .add(jButton13))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel18)
                        .add(18, 18, 18)
                        .add(jButton12)))
                .addContainerGap(550, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton7)
                    .add(jButton11))
                .add(39, 39, 39)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel18)
                    .add(jButton12))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel19)
                    .add(jButton13))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel20)
                    .add(jButton14))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel22)
                    .add(jButton15))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel21)
                    .add(jButton16))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel23)
                    .add(jButton17))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel25)
                    .add(jButton18))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel24)
                    .add(jButton19))
                .addContainerGap(77, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("My Shared Pictures", jPanel2);

        jButton3.setText("Profile");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jTabbedPane1)
                        .addContainerGap())
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(0, 622, Short.MAX_VALUE)
                        .add(jButton3)
                        .add(36, 36, 36)
                        .add(jButton2)
                        .add(30, 30, 30))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap(31, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton2)
                    .add(jButton3))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 482, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        this.dispose();
        Search search=new Search();
        search.setVisible(true); 
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
        Profile profile = new Profile();
        profile.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        //CLOSE THE SESSION
        Login login = new Login();
        login.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jLabel14MouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel14MouseExited
        // TODO add your handling code here:
        Cursor c2 = new Cursor(Cursor.DEFAULT_CURSOR);
        setCursor(c2);
    }//GEN-LAST:event_jLabel14MouseExited

    private void jLabel14MouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel14MouseEntered
        // TODO add your handling code here:
        Cursor c1 = new Cursor(Cursor.HAND_CURSOR);
        setCursor(c1);
    }//GEN-LAST:event_jLabel14MouseEntered

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        //InstantMessage im=ImpInstantMessage.getIntanceMessage();
        int i=0;
        Photo photo=new Photo();
        String path=null;
        String nam=null;
        for (Object o: ph){
            photo=(Photo)o; 
            if(i==0){
                path=photo.getPath();
                nam=photo.getTitle();
                path=path+nam;
            }
            log.info("path????????? "+path );
            i++;         
        }
        im.sendMessageUserContent(im.getXMPPConnection().getUser(),im.getXMPPConnection().getUser(), path, userTo);
        javax.swing.JOptionPane.showMessageDialog(null, "Download complete!");
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
         int i=0;
        Photo photo=new Photo();
        String path=null;
        String nam=null;
        for (Object o: ph){
            photo=(Photo)o; 
            if(i==1){
                path=photo.getPath();
                nam=photo.getTitle();
                path=path+nam;
            }
            log.info("path????????? "+path );
            i++;         
        }
        im.sendMessageUserContent(im.getXMPPConnection().getUser(),im.getXMPPConnection().getUser(), path, userTo);
        javax.swing.JOptionPane.showMessageDialog(null, "Download complete!");
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
         int i=0;
        Photo photo=new Photo();
        String path=null;
        String nam=null;
        for (Object o: ph){
            photo=(Photo)o; 
            if(i==2){
                path=photo.getPath();
                nam=photo.getTitle();
                path=path+nam;
            }
            log.info("path????????? "+path );
            i++;         
        }
        im.sendMessageUserContent(im.getXMPPConnection().getUser(),im.getXMPPConnection().getUser(), path, userTo);
        javax.swing.JOptionPane.showMessageDialog(null, "Download complete!");
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
         int i=0;
        Photo photo=new Photo();
        String path=null;
        String nam=null;
        for (Object o: ph){
            photo=(Photo)o; 
            if(i==3){
                path=photo.getPath();
                nam=photo.getTitle();
                path=path+nam;
            }
            log.info("path????????? "+path );
            i++;         
        }
        im.sendMessageUserContent(im.getXMPPConnection().getUser(),im.getXMPPConnection().getUser(), path, userTo);
        javax.swing.JOptionPane.showMessageDialog(null, "Download complete!");
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
         int i=0;
        Photo photo=new Photo();
        String path=null;
        String nam=null;
        for (Object o: ph){
            photo=(Photo)o; 
            if(i==4){
                path=photo.getPath();
                nam=photo.getTitle();
                path=path+nam;
            }
            log.info("path????????? "+path );
            i++;         
        }
        im.sendMessageUserContent(im.getXMPPConnection().getUser(),im.getXMPPConnection().getUser(), path, userTo);
        javax.swing.JOptionPane.showMessageDialog(null, "Download complete!");
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
         int i=0;
        Photo photo=new Photo();
        String path=null;
        String nam=null;
        for (Object o: ph){
            photo=(Photo)o; 
            if(i==5){
                path=photo.getPath();
                nam=photo.getTitle();
                path=path+nam;
            }
            log.info("path????????? "+path );
            i++;         
        }
        im.sendMessageUserContent(im.getXMPPConnection().getUser(),im.getXMPPConnection().getUser(), path, userTo);
        javax.swing.JOptionPane.showMessageDialog(null, "Download complete!");
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        JFileChooser chooser = new JFileChooser();
        // Note: source for ExampleFileFilter can be found in FileChooserDemo,
        // under the demo/jfc directory in the Java 2 SDK, Standard Edition.
        int returnVal = chooser.showOpenDialog(ShowThumbnails.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String name = chooser.getSelectedFile().getName();
            String path = chooser.getSelectedFile().getPath();
            UploadPicture upload = new UploadPicture(path, name);
            upload.setVisible(true);
            this.dispose();
        }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
        // LAUNCH WEB
        //String url="untitled.html?i1="+paths[0]+title[0]+"&i2="+paths[1]+title[1]+"&i3="+paths[2]+title[2];
        String mipath = System.getProperty("user.dir");
        String miOS = System.getProperty("os.name");
        System.out.println(miOS);
        if (miOS.equals("Mac OS X") == true) {
            String url = "file://" + mipath + "/untitled.html?i1=" + "flower.jpg" + "&i2=" + "people.png";
            System.out.println(url);
            openURL(url);
        } else {
            JOptionPane.showMessageDialog(null, "Por ahora solo funciona con MAC");
        }
    }//GEN-LAST:event_jButton11ActionPerformed

    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton12ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[0], title[0]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton12ActionPerformed

    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton13ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[1], title[1]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton13ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[2], title[2]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton14ActionPerformed

    private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton15ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[3], title[3]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton15ActionPerformed

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[4], title[4]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton16ActionPerformed

    private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton17ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[5], title[5]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton17ActionPerformed

    private void jButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton18ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[6], title[6]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton18ActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
        // TODO add your handling code here:
        ImageSelection img = new ImageSelection(paths[7], title[7]);
        img.setVisible(true);
        this.dispose();
    }//GEN-LAST:event_jButton19ActionPerformed

    /**
     * @param args the command line arguments
    */ 
   
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ShowThumbnails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ShowThumbnails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ShowThumbnails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ShowThumbnails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ShowThumbnails().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTabbedPane jTabbedPane1;
    // End of variables declaration//GEN-END:variables
    private String pathThumb1, pathThumb2;
    private String pathImage;
    ImageIcon icon1, icon2;
    public JLabel labels[];
    //String title[];
    public JLabel l1;
    ImpInstantMessage im;
    String userTo;
    List<Object> ph;
    List<Object> list;
    int button=0;
    private String stringSent=null;
    String title[], paths[];
    String[] titleMyphoto;
    
             private void showMyImages(){
        com.mycompany.chatapp.Databaseacces.ImpDBManager dbmanager;
        dbmanager=  com.mycompany.chatapp.Databaseacces.ImpDBManager.getInstanceManager();
        ImpDBAction action =null;
        action = new ImpDBAction();
        action.setActionId("consulta.imagen.todo");
        ImpDBActionResult result=null;
        result = dbmanager.execute(action);
        list=result.getResult();
        
        titleMyphoto=new String[8];
        for(int j=0;j<8;j++){
            titleMyphoto[j]=" ";
        }
        
        paths=new String[8];
        for(int j=0;j<8;j++){
            paths[j]=" ";
        }
        
        int i=0;
        Photo ph=new Photo();
        for (Object o: list){
            ph=(Photo)o;
            titleMyphoto[i]=ph.getTitle();
            paths[i]=ph.getPath()+ph.getTitle();
            i++;
        }
    }

    
}
